package kr.board.validator;

import kr.board.domain.BoardCommand;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;


public class BoardValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return BoardCommand.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		
		System.out.println(target);
		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "b_title", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "b_content", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "m_id", "required");
	}

}
